package com.uroad.jilinpda.util;

import android.content.Context;
import android.content.pm.ApplicationInfo;

/**
 * @author 40377
 * @version V1.0
 * @Date 2020/5/6 13:34
 * @Description: ${TODO}(根据application的debuggable值自动修改isDebug值)
 */
public class AppUtils {

    public static Boolean isDebug = null;

    /**
     * 判断当前包是否是debug版本
     * @return
     */
    public static boolean isDebug(){
        return isDebug == null ? false : isDebug.booleanValue();
    }

    /**
     * 需要在application中调用进行初始化 AppUtils.syncIdDebug(getApplicationContext());
     * @param context
     */
    public static void syncIsDebug(Context context) {
        if (isDebug == null) {
            isDebug = context.getApplicationInfo() != null &&
                    (context.getApplicationInfo().flags & ApplicationInfo.FLAG_DEBUGGABLE) != 0;
        }
    }

}
